package com.seirsoft.cookingtime.controller;

import com.seirsoft.cookingtime.internal.ICtlBase;
import com.seirsoft.cookingtime.view.IDlgBase;

public abstract class CtlDlgBase implements ICtlBase 
{
	protected IDlgBase m_dialog = null;
	public CtlDlgBase(IDlgBase dlgBase)
	{
		if(dlgBase != null)
		{
			this.m_dialog = dlgBase;
			this.m_dialog.setController(this);
		}
	}
	
	@Override
	public void fireEventDialogClosed() {
	}
	@Override
	public void fireEventUIPreCreate()	{
	}
	
	@Override
	public void fireEventButtonClickOK() {
		this.m_dialog.closeDialog(true);
	}

	@Override
	public void fireEventButtonClickCancel() {
		this.m_dialog.closeDialog(false);
	}
	
	public void open()
	{
		if(isValid())
		{
			this.m_dialog.openDialog();
		}
	}
	
	public boolean isValid()
	{
		return this.m_dialog != null;
	}
}
